package day07;

import java.util.Scanner;

/*
买飞机票，旺季（5-10月），头等舱9折，经济舱8.5折，经济舱7折
        淡季（11-4月），头等舱8折，商务舱7.5折，经济舱6折
 */
public class CalAirPrice1 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入原价：");
        double calPrice = scan.nextDouble();
        System.out.println("请选择月份：");
        int month = scan.nextInt();
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int airSpace = scan.nextInt();
        double finalPrice = payAirCheck(calPrice,month,airSpace );
        if(finalPrice!=-1){
            System.out.println("最终的机票价格是："+finalPrice);
        }


    }
    //买票
    public static double payAirCheck(double calPrice,int month,int airSpace){
       double check =0.0;
        if(calPrice<0) {
            System.out.println("输入的原价有误");
            return -1;
        }
        if(month<0||month>12) {
            System.out.println("输入的月份有误");
            return -1;
        }
        if(airSpace<1||airSpace>3){
            System.out.println("输入的舱位错误");
            return -1;
        }
        if(month>=5||month<=10){
            switch (airSpace){
                case 1: check = calPrice*0.9;
                break;
                case 2: check = calPrice*0.85;
                break;
                case 3: check = calPrice*0.7;
                break;
            }
        }else {
            switch (airSpace){
                case 1: check = calPrice*0.8;
                break;
                case 2: check = calPrice*0.75;
                break;
                case 3: check = calPrice*0.6;
                break;
            }
        }
        return check;
        }
    }


